#include<iostream>
using namespace std;


void dfs(int n, char a, char b, char c)
{
	if(n==0) return ;
	dfs(n-1, a, c, b);
	printf("%c->%d->%c\n", a, n, b);
	dfs(n-1, c, b, a);
}
int main()
{
	int n; cin>>n;
	char a, b, c;
	cin>>a>>b>>c;
	dfs(n, a, b, c);
	return 0;
 } 
